www.gusucode.com > 基于VBLAST-OFDM的MATLAB SIMULATION,图形化界面,并且给出了各仿真图 > 基于VBLAST-OFDM的MATLAB SIMULATION,图形化界面,并且给出了各仿真图/vblast-ofdm simulation/get_channel_ir.m

    function [cir] = get_channel_ir(SimulationParameters);

global SimulationConstants;

[n_tx_antennas, n_rx_antennas] = get_n_antennas(SimulationParameters);

n_channels = n_tx_antennas*n_rx_antennas;

temp=SimulationConstants.SamplingFrequency;
K=SimulationParameters.kfactor; 
RDS=SimulationParameters.TimeMaxDelay;


if ~isempty(findstr(SimulationParameters.ChannelModel, 'Rayleigh')) 
   if SimulationParameters.TimeMaxDelay == 0
      Kmax = 0;
      vark = 1;
   else
      % Calculate the exponential decay envelope
      Kmax = ceil( 10 * (SimulationParameters.TimeMaxDelay*(1e-9))*temp);
      var0 = (1 - exp( - 1/(temp*(SimulationParameters.TimeMaxDelay*(1e-9))))) / ...
         (1 - exp( -1*((Kmax+1)*temp/(SimulationParameters.TimeMaxDelay*(1e-9)))));
      k = (0:Kmax);
      env = var0 * exp( - k/(temp*(SimulationParameters.TimeMaxDelay*(1e-9))));
   end
   
   stdDevReOrIm = sqrt(env/2);
   cir = repmat(stdDevReOrIm, n_channels,1) .* (randn(n_channels, Kmax+1) + j*randn(n_channels, Kmax+1));
elseif ~isempty(findstr(SimulationParameters.ChannelModel, 'AWGN'))
   cir = ones(n_channels,1);
elseif ~isempty(findstr(SimulationParameters.ChannelModel, 'Rician'))
    if SimulationParameters.TimeMaxDelay == 0
      Kmax = 0;
      vark = 1;
   else
      % Calculate the exponential decay envelope
      Kmax = ceil( 10 * (SimulationParameters.TimeMaxDelay*(1e-9))*temp);
      var0 = (1 - exp( - 1/(temp*(SimulationParameters.TimeMaxDelay*(1e-9))))) / ...
         (1 - exp( -1*((Kmax+1)*temp/(SimulationParameters.TimeMaxDelay*(1e-9)))));
      k = (0:Kmax);
      env = (K+var0) * exp( -K- ((K+1)*k)/(temp*(SimulationParameters.TimeMaxDelay*(1e-9)))).*besselj(0,2*sqrt(K*(K+1)*k)); %see eqn(2.51) 
                                        %"Principles of Mobile Communication", 2nd edition,Gordon Stuber:we add the rician K factor

   end
   
   stdDevReOrIm = sqrt(env/2);
   cir = repmat(stdDevReOrIm, n_channels,1) .* (randn(n_channels, Kmax+1) + j*randn(n_channels, Kmax+1));
else
   error('Undefined channel model');
end